//
//  MYSelectContactCell.m
//  JQLive
//
//  Created by Bruce on 2020/3/31.
//  Copyright © 2020 JQLive. All rights reserved.
//

#import "MYSelectContactCell.h"

@implementation MYSelectContactCell

- (void)initView
{
    self.selectedBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.selectedBtn.userInteractionEnabled = NO;
    [self.selectedBtn setImage:[UIImage imageNamed:@"ic_p_un_select"] forState:0];
    [self.selectedBtn setImage:[UIImage imageNamed:@"ic_p_select"] forState:UIControlStateSelected];
    [self.contentView addSubview:self.selectedBtn];
    
    self.contactAvatarImg = [[UIImageView alloc] init];
    self.contactAvatarImg.layer.masksToBounds = YES;
    self.contactAvatarImg.contentMode = UIViewContentModeScaleAspectFill;
    self.contactAvatarImg.layer.cornerRadius = 36/2;
    [self.contentView addSubview:self.contactAvatarImg];
    
    self.contactNameLabel = [[UILabel alloc] init];
    self.contactNameLabel.textColor = MY_Text_Color_Theme1;
    self.contactNameLabel.font = [UIFont systemFontOfSize:16];
    self.contactNameLabel.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:self.contactNameLabel];
    
    [self.selectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(@(MY_Padding));
    }];
    
    [self.contactAvatarImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.selectedBtn.mas_right).offset(10);
        make.width.height.equalTo(@36);
    }];
    
    [self.contactNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contactAvatarImg.mas_right).offset(10);
    }];
}

- (void)prepareForReuse
{
    [super prepareForReuse];
    _selectedBtn.selected = NO;
    [_selectedBtn setImage:[UIImage imageNamed:@"ic_p_un_select"] forState:(UIControlStateNormal)];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    [self.selectedBtn.imageView addBouncesAnimation];
}

@end
